<template>
    <div class="add">
        <!-- <h1>当前最新的count值为：{{count}}</h1> -->
        <h1>{{$store.getters.showNum}}</h1>
        <button @click="sub1">-1</button>
        <button @click="sub(2)">-2</button>
        <button @click="sub5">-5</button>
        <button @click="subAsync(1)">-1 Async</button>
    </div>
</template>
<script>
import {mapState,mapMutations, mapActions} from "vuex"
export default {
    data(){
        return{
            
        }
    },
    methods:{
        ...mapMutations(["sub"]),
        ...mapActions(["subAsync"]),
        sub1(){
            this.$store.commit("sub",1)
        },
        sub5(){
            this.$store.commit("sub",5)
        },
    },
    computed:{
        ...mapState(["count"])
    }
}
</script>